<%-- 
    Document   : kumpulan_tambah
    Created on : Nov 5, 2012, 2:24:04 PM
    Author     : faizal.azlee
--%>
<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>Jawab Tawaran Tunai Haji</title>
     <script type="text/javascript">
        var mygridHRes;
        var runid_HRes = 0;
        var dp_HRes;
        var xwin = new Array();
        xwin[0] = null;
            $(document).ready(function(){
                $('form').submit( 
                    function () {
                        return formValidation();
                    }
                );
                initDhxWins();
                prepareGridHRes(); 
                    <%
                     if(request.getSession().getAttribute("ReturnMessages")!= null){            
                    %>
                       //popupMsg();
                    <%
                         }
                    %> 
                }
            ); 
            
            function prepareGridHRes()
            {
                mygridHRes = new dhtmlXGridObject('gridHRes');
                mygridHRes.setImagePath("<%=request.getContextPath()%>/resources/codebase/imgs/");
                mygridHRes.setSkin("modern");
                mygridHRes.init();

                dp_HRes = new dataProcessor("<%=request.getContextPath()%>/resources/xml/dp.jsp");
                dp_HRes.setUpdateMode("off");
                dp_HRes.setTransactionMode("POST",true);
                dp_HRes.init(mygridHRes);
                loadGridHRes();           
            }            
            
            var gridHResLoaded = false;
            function loadGridHRes()
            {               
                if(gridHResLoaded) return;
                gridHResLoaded = true; 
                mygridHRes.loadXML("<%=request.getContextPath()%>/resources/xml/hajjresxml.jsp", doAfterLoadgridHRes);            
            }

            function doAfterLoadgridHRes(){
                //after load
            }
            
        var dhxWins;
        var dhxpopup;
        //define dhtmlx popup window
        function initDhxWins()
        {
            dhxWins = new dhtmlXWindows();
            dhxWins.setImagePath("<%=request.getContextPath()%>/resources/codebase/imgs/");
            dhxWins.enableAutoViewport(false);
            dhxWins.attachViewportTo("detail-div");
            
            dhxpopup = new dhtmlXWindows();
            dhxpopup.setImagePath("<%=request.getContextPath()%>/resources/codebase/imgs/");
            dhxpopup.enableAutoViewport(false);
            dhxpopup.attachViewportTo("detail-div");
        }
        
        //popup window and add member into grid
        function goAddGroupMember(noAkaunPenambah){
            var gsize = mygridHRes.getRowsNum();
            if(gsize>=10){
                alert("Had maksimum Jawab Tawaran  adalah seramai 10 orang");
                return true;
            }            
            var gridDiv = document.getElementById("gridHRes-div");
            var gridDivPostX = findPositionX(gridDiv);
            var gridDivPostY = findPositionY(gridDiv);
            if(!dhxWins.isWindow('plusW')){
                var winObj = dhxWins.createWindow("plusW", gridDivPostX+30, gridDivPostY-100, 550, 300);
                winObj.setText("");
//                winObj.hideHeader();
//                winObj.button('minmax1').hide();
//                winObj.button('minmax2').hide();
//                winObj.button('park').hide();
                winObj.setModal(true);
                winObj.denyMove();
                winObj.attachURL('<%=request.getContextPath()%>/haji/response?showPopupTambahAhliKumpulan&noAkaunPenambah='+noAkaunPenambah, false);
            }
        }
        
        //popup window and add member into grid
        function goEditGroupMember(idKumpulan){
            var gridDiv = document.getElementById("gridHRes-div");
            var gridDivPostX = findPositionX(gridDiv);
            var gridDivPostY = findPositionY(gridDiv);
            if(!dhxWins.isWindow('plusW')){
                var winObj = dhxWins.createWindow("plusW", gridDivPostX+30, gridDivPostY-100, 550, 400);
                winObj.setText("");
//                winObj.hideHeader();
//                winObj.button('minmax1').hide();
//                winObj.button('minmax2').hide();
//                winObj.button('park').hide();
                winObj.setModal(true);
                winObj.denyMove();
                winObj.attachURL('<%=request.getContextPath()%>/haji/response?showPopupEditAhliKumpulan&idKumpulan='+idKumpulan, false);
            }
        }
        
        var winMsgObj;        
        
        function popupMsg()
        {
            if(!dhxpopup.isWindow('msgW'))
            {
//                var obj = document.getElementById('gridHRes-div');
//                var x = findPosX(obj);
//                var y = findPosY(obj);
//                var h = obj.offsetHeight;
//                var w = obj.offsetWidth;
//                var h1 = 100;
//                var w1 = 250;
//                var x1 = x+(w/2)-(w1/2);
//                var y1 = y+(h/2)-(h1/2);
                
                var gridDiv = document.getElementById("gridHRes-div");
                var gridDivPostX = findPositionX(gridDiv);
                var gridDivPostY = findPositionY(gridDiv);
            
                winMsgObj = dhxpopup.createWindow("msgW", gridDivPostX, gridDivPostY, 350, 200);
                winMsgObj.setText('Save');
                winMsgObj.button('minmax1').hide();
                winMsgObj.button('minmax2').hide();
                winMsgObj.button('park').hide();
                winMsgObj.setModal(true);
                winMsgObj.hideHeader();
                winMsgObj.attachURL('<%=request.getContextPath()%>/resources/codebase/ajaxmsg.jsp', false);
            }
        } 
        
        function animateSaving(isAjax)
        {
            if(!dhxpopup.isWindow('msgW'))
            {
                var obj = document.getElementById('gridHRes');
                var x = findPosX(obj);
                var y = findPosY(obj);
                var h = obj.offsetHeight;
                var w = obj.offsetWidth;
                var h1 = 100;
                var w1 = 250;
                var x1 = x+(w/2)-(w1/2);
                var y1 = y+(h/2)-(h1/2);
                winMsgObj = dhxpopup.createWindow("msgW", x1, y1, 350, 200);
                winMsgObj.setText('Save');
                winMsgObj.button('minmax1').hide();
                winMsgObj.button('minmax2').hide();
                winMsgObj.button('park').hide();
                winMsgObj.setModal(true);
                winMsgObj.hideHeader();
//                winMsgObj.centerOnScreen();
                if(isAjax)
                    winMsgObj.attachURL('<%=request.getContextPath()%>/resources/codebase/saving.jsp', false);
                else
                    endAnimation();
            }
        } 
        
        function endAnimation(){
            winMsgObj.attachURL('<%=request.getContextPath()%>/resources/codebase/ajaxmsg.jsp', false);
        } 
        
        function goDeleteAhliKumpulan(id){
            var url = "${pageContext.request.contextPath}/haji/response?deleteAhliKumpulan&idKumpulan="+id;
            //animateSaving(true);           
            $.ajax({
                    url : url,
                    dataType : "html",  
                    data: "",
                    type: "get",
                    success: function(data) {
                        gridHResLoaded = false;
                        loadGridHRes();                      
                        //popupMsg();
                    }
                    ,
                    error : function() {
//                            alert("Sorry, The requested property could not be found.");
                    }
            });
        }
        
        function goDeleteAllMembers(noAkaun){
            var f = document.forms[0];
                f.action = "${pageContext.request.contextPath}/haji/response?removeKumpulan&noAkaun="+noAkaun;
                f.submit();
        }
        
        function redirectToHomePage(f){
            var url = '${pageContext.request.contextPath}/haji?showMainForm';
            f.action = url;
            f.submit();
        }
        
        
        function findPositionX(obj)
            {
                var curleft = 0;
                if(obj.offsetParent)
                    while(1)
                    {
                      curleft += obj.offsetLeft;
                      if(!obj.offsetParent)
                        break;
                      obj = obj.offsetParent;
                    }
                else if(obj.x)
                    curleft += obj.x;
                return curleft;
            }

            function findPositionY(obj)
            {
                var curtop = 0;
                if(obj.offsetParent)
                    while(1)
                    {
                      curtop += obj.offsetTop;
                      if(!obj.offsetParent)
                        break;
                      obj = obj.offsetParent;
                    }
                else if(obj.y)
                    curtop += obj.y;
                return curtop;
            }
   
//            function validate(){
//               if (document.getElementById("senaraiMaklumatKump").value!="") {
//                    alert("Senarai maklumat Kumpulan");
//                    var s = document.getElementById("senaraiMaklumatKump").value;
//                    if (s.length() != 0) {
//                          alert("Senarai maklumat Kumpulan != 0");
//
//                    }
//                }
//                else{
//                    return true;
//                }
//            }
        
             function validate1(f)
            {            
             if(validate()){
                blockUI();
                
                f.action = '${pageContext.request.contextPath}/haji/response?HajjResp_Step7';
                f.submit();
            }
            }
   
     </script>
      <style>
        #content label {
            width : 15em;
        }
        .boxed {
            border: 1px dashed #3d9f3b;
            padding-left: 20px;
            padding-bottom: 10px;
            padding-top: 10px;
            width: 650px;
            background-color: #d5fbd5;
            font-size: 9pt;
         }
    </style>
    </head>
    <body>
    <s:messages/>
<s:errors/> 
        <br/>
        <s:form beanclass="th.stripes.action.HajiResponseActionBean" class="niceform">
        <s:hidden name="haji.noAkaun" id="noAkaun"></s:hidden>
        <s:hidden name="haji.maklumatKumpulan.noAkaun" id="noAkaunKumpulan"></s:hidden>
      <%-- <s:hidden name="permohonanMaklumat.getSenaraiMaklumatKumpulan" id="senaraiMaklumatKump"/>--%>
            <div id="content">
            <div id="logo">
                <span>
                    <img src="${pageContext.request.contextPath}/images/img/ribbon.png"/>               
                </span>
            </div>
            <h3>
                Jawab Tawaran Tunai Haji
            </h3> 
                <p>
                     <label>Nama :</label>${actionBean.haji.mohonMaklumat.nama} 
                </p>
                <p>
                    <label>No. Akaun TH :</label>${actionBean.haji.mohonMaklumat.noAkaun}
                </p>
                <p>
                    <label>No. KP Semasa :</label>${actionBean.haji.mohonMaklumat.noPengenalan}
                </p>
                <p>
                    Tuan / Puan telah mempunyai pilihan penerbangan dan kod keluarga seperti berikut :
                </p>
                <p>
                <b>Pilihan Penerbangan ke Tanah Suci</b>
                </p>
                <p>
                    <label>Lapangan Terbang Berlepas :</label>${actionBean.haji.destinasiPergi}
                    <%--<label>Lapangan Terbang :</label> ${actionBean.haji.destinasiPergi}
                        <s:select name="haji.destinasiPergi" onchange="submitDestinasi(${actionBean.haji.mohonMaklumat.idMohonMaklumat})" id="origin" disabled="true">
                        <s:option value="">Please select</s:option>
                        <s:option value="">Sila Pilih</s:option>
                        <s:option value="AOR">Alor Star</s:option>
                        <s:option value="JHB">Johor Bharu</s:option>
                        <s:option value="BKI">Kota Kinabalu</s:option> 
                        <s:option value="KUL">Kuala Lumpur</s:option>
                        <s:option value="TGG">Kuala Terengganu</s:option>
                        <s:option value="KCH">Kuching</s:option>                                                           
                        <s:option value="PEN">Pulau Pinang</s:option>
                   </s:select>--%> 
                </p>
                <p>
                    <label>Destinasi ke Tanah Suci : </label>${actionBean.haji.destinasiBalik}
                    <%-- <label>Destinasi : </label> ${actionBean.haji.destinasiBalik}
                        <s:select name="haji.destinasiBalik" onchange="submitDestinasi(${actionBean.haji.mohonMaklumat.idMohonMaklumat})" id="destinasi" disabled="true">
                        <s:option value="">Please select</s:option> 
                        <s:option value="MD">Madinah</s:option>
                        <s:option value="MK">Mekah</s:option>                                                         
                    </s:select>--%>
                </p> 
                <p>
                    <b>Kod Keluarga</b>
                </p>
                <p>
                    <label> Kod Keluarga : </label>${actionBean.haji.idKumpulan}
                </p>
                <p>
                 <div class="boxed">
                    <b>Nota</b><br/>
                        1. Ahli Keluarga / Mahram yang akan pergi bersama hendaklah tidak melebihi 10 orang.<br/>
                        2. Klik "+" untuk Tambah Ahli Keluarga.<br/>
                        3. Sila Pastikan Anda Kemaskini Pertalian Sebelum Anda Klik 'Hantar'.<br/>
                </div>
            </p>
                <br>
                <div style="z-index: -2" id="gridHRes-div">
                    <input type="hidden" id="deleteGroupIds">
                    <div id="gridHRes" style="width:100%; height:200px; background-color:white;overflow:hidden; z-index: 2"></div>
                </div> 
<!--                <br>
                Nota : Sila Pastikan Anda Kemaskini Hubungan Sebelum Anda Klik 'Hantar'.
                       Ahli Keluarga / Mahram yang akan pergi bersama hendaklah tidak melebihi 10 orang.
                -->
                <br><br>
                <div align="center">
                    <s:button name="halamutama" value="Halaman Utama" onclick="redirectToHomePage(this.form);" class="button green"/> 
                    <s:submit name="HajjResp_Step8" value="Batal" class="button green" />
                    <s:submit name="kembali" value="Kembali" class="button green"/>
                    <s:submit name="HajjResp_Step7"  value="Hantar" class="button green button_blockUI"/> 
                    <%--<s:button name="hantar"  value="Hantar" class="button green" onclick="validate1(this.form);"/>--%>
                </div>         
        </div>
        </s:form>
    </body>
</html>
